<?php
/**
 * Created by PhpStorm.
 * User: rocky
 * Date: 2019-07-14
 * Time: 01:24
 */

namespace app\shop\resource;

use app\common\model\ArticleCollect;
use app\common\resource\BaseResource;

class OrderResoure extends BaseResource
{
    public function toArray($data)
    {
        if ($data['express_type'] == 2 && $data['status'] == 3) {
            $data['status'] = 5;
        }
        return [
            'id' => $data['id'],
            'order_no' => $data['order_no'],
            'goods_price' => $data['goods_price'],
            'express_type' => $data['express_type'],
            'freight_price' => $data['freight_price'],
            'pay_price' => $data['pay_price'],
            'name' => $data['address_info']['name'],
            'phone' => $data['address_info']['phone'],
            'full_address' => $data['address_info']['full_address'],
            'total_price' => $data['total_price'],
            'status' => $data['status'],
            'pay_time' => $data['pay_time'],
            'desc' => $data['desc'],
            'express_id'=>$data['express']['id'],
            'delivery_time' => $data['express']['create_at'],
            'cancel_time'=>date('Y-m-d H:i:s',  strtotime($data['create_at']) + sysconf('order_cancel_time') * 3600),
            'confim_time' => date('Y-m-d H:i:s',  strtotime($data['express']['create_at']) + sysconf('order_confirm_time') * 3600 * 24),
            'goods' => OrderGoodResoure::collection($data['good']),
            'create_at' => $data['create_at'],
        ];
    }

}